﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Data;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;

namespace QuanLyThuNgan
{
    public partial class rpt_InThanhToanXuatVien : DevExpress.XtraReports.UI.XtraReport
    {
        public rpt_InThanhToanXuatVien()
        {
            InitializeComponent();
        }

        ThuDTLCTL thuDTLCtl = new ThuDTLCTL();
        public string sSohs, sHoTen, sGioiTinh, sNamSinh, sKhoa, sSoNhapVien, sDiaChi;
        public string sTienVienPhi, sTienTamUng, sTienBHYT, sTienHoanTra;
        string sNgay, sNguoiNhap, sSoBienNhan;
        
        private void rpt_InThanhToanXuatVien_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {

            sNgay = Uit.it_Date.CurrentDate("dd/MM/yyyy");
            DataTable dtxv = thuDTLCtl.m_InThanhToanXuatVien(sSohs, sSoNhapVien);
            sSoBienNhan = dtxv.Rows[0]["sobn"].ToString();
            sNguoiNhap = dtxv.Rows[0]["HoTen"].ToString();
            //load to report form---------------------------------------------------
            xrlMaSohs.Text = cbarcode.Bar128(sSohs);
            xrLNgay.Text = sNgay;
            xrLSobn.Text = sSoBienNhan;
            xrLNguoiLap.Text = sNguoiNhap;
            //load value from Frm_ThanhToanXV---------------------------------------

            xrLSohs.Text = sSohs;
            xrLSonv.Text = sSoNhapVien;
            xrLHoTen.Text = sHoTen;
            xrLGioiTinh.Text = sGioiTinh;
            xrLNamSinh.Text = sNamSinh;
            xrLDiaChi.Text = sDiaChi;
            xrLKhoa.Text = sKhoa;
            xrLTienVienPhi.Text = sTienVienPhi;
            xrLTienTamUng.Text = sTienTamUng;
            xrLBHYTThanhToan.Text = sTienBHYT;
            
            Clsdocso dos = new Clsdocso();
            if ( Uit.it_Parse.ToInteger(sTienHoanTra) < 0)
            {
                xrLTienHoanTra.Text = Uit.it_Parse.ToString((Uit.it_Parse.ToInteger(sTienHoanTra))*(-1));
                xrLTienThuThem.Text = "0";
                xrLTienBangChu.Text = dos.Doc(long.Parse(Uit.it_Parse.ToString(Uit.it_Parse.ToInteger(sTienHoanTra)*(-1))));
            }
            else
            {
                if (Uit.it_Parse.ToInteger(sTienHoanTra) > 0)
                {
                    xrLTienHoanTra.Text = "0";
                    xrLTienThuThem.Text = Uit.it_Parse.ToString(sTienHoanTra);
                    xrLTienBangChu.Text = dos.Doc(long.Parse(sTienHoanTra));
                }
                else
                {
                    if (Uit.it_Parse.ToInteger(sTienHoanTra) == 0)
                    {
                        xrLTienHoanTra.Text = sTienHoanTra;
                        xrLTienThuThem.Text = sTienHoanTra;
                        xrLTienBangChu.Text = dos.Doc(long.Parse(sTienHoanTra));
                    }
                }
            }
            
        }
    }
}
